package leilib.ir.crawler.url;

import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;

public class CrawlURLTest {
	CrawlURL url2;

	private String url = "http://www.bAiDu.com/index.html";
	private String ip = "222.12.16.225";

	@Before
	public void setUp() throws Exception {
		url2 = new CrawlURL(url);
		url2.setIpAddress(ip);

	}

	@Test
	public void testGetURLWithHost() {
		// System.out.println(url2.getURLWithHost());
		assertNotNull(url2.getURLWithHost());
	}

	@Test
	public void testGetURLWithAddress() {
		// System.out.println(url2.getURLWithAddress());
		assertNotNull(url2.getURLWithAddress());
	}

	@Test
	public void testGetMD5String() {
		System.out.println(url2.getMD5String());
		assertNotNull(url2.getMD5String());
	}

	@Test
	public void testGetIpAddress() {
		assertEquals(this.ip, url2.getIpAddress());
	}

	@Test
	public void testGetHttpURL() {
		String s = this.url2.getHostURL();
		System.out.println(this.url2.getPort());
		assertEquals("http://www.baidu.com:80", s);
	}

}
